package com.kehutong.payfees.service;

import java.util.List;
import java.util.stream.Collectors;

import org.coraframework.inject.Inject;
import org.coraframework.mvc.webservice.WebService;
import org.coraframework.orm.Pool;
import org.coraframework.orm.jdbc.JdbcSession;

import com.kehutong.payfees.entity.ChargeBillAnnex;
import com.kehutong.payfees.enums.ChargeAnnexType;

/**
 * Author:  peter
 * Date:    2020/7/10
 * Function:缴费账单-附件
 */
@WebService("/payfees/charge/annex")
public class ChargeBillAnnexServiceImpl {

    @Inject
    protected JdbcSession jdbcSession;

    public void doInsertBillAnnex(String billNo, List<String> fileIds, ChargeAnnexType type) {
        List<ChargeBillAnnex> annexes = fileIds.stream()
                .map(fileId -> {
                    ChargeBillAnnex annex = Pool.newInstance(ChargeBillAnnex.class);
                    annex.setBillNo(billNo);
                    annex.setType(type);
                    annex.setFileId(fileId);
                    return annex;
                }).collect(Collectors.toList());

        jdbcSession.insert(annexes);
    }

}
